<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$url=urlencode($url);
$bzxtvbb=urlencode($bzxtvbb);
$Bingz_xturl=''.$Bingz_url_upgrade.'/Bingz_upload.php?bvb='.$bzxtvbb.'&url='.$url.'';
$body=@file_get_contents($Bingz_xturl);
     if(@preg_match("/\<banb\>(.*?)<\/banb\>/i",$body,$smsa)){
       $Bingza=$smsa[1];
       $Bingzapf=$smsa[1];
     }else{
       $Bingza='获取版本失败';
     }

     if(@preg_match("/\<sjsj\>(.*?)<\/sjsj\>/i",$body,$smsb)){
       $Bingzb=$smsb[1];
     }else{
       $Bingzb='获取时间失败';
     }

     if(@preg_match("/\<sjsm\>(.*?)<\/sjsm\>/i",$body,$smsc)){
       $Bingzc=str_replace("@",'///',$smsc[1]);
     }else{
       $Bingzc='获取介绍失败';
     }
if($_GET[upload] == 'upload'){
echo"<div class='admin'>在线升级程序<br/></div>";
     if(!$smsa[1]){
		     echo"你好！获取升级数据失败！";
     }else if($Bingza > $bzxtvbb ){
       if(preg_match("/\<zsql\>(.*?)<\/zsql\>/i",$body,$sms)){
       	  if($sms[1]){
    	       $amm=Bingz_upload_Remote('data/',$sms[1],'sql');
    	       if($amm[1] == '1'){
    	   	       $smtabb=hfsjk_sql("data/".$amm[2]);
			           echo"【<b>数据库升级</b>】执行成功！<br/>执行结果：$smtabb<br/>";
		             @unlink("data/".$amm[2]);
             }else{
		             echo"【<b>数据库升级</b>】下载升级数据库文件失败！$amm[2]<br/>";
             }
          }else{
		             echo"【<b>数据库升级</b>】获取升级数据库文件失败！<br/>";
          }
       }
       if(preg_match("/\<zurl\>(.*?)<\/zurl\>/i",$body,$smsbb)){
          if($smsbb[1]){
          	$bzwjc=Bingz_upload_Remote('cache/',$smsbb[1],'zip');
    	      if($bzwjc[1] == '1'){
			         $sjwe=zip("cache/".$bzwjc[2],'./');
			         if($sjwe){
			            echo"【<b>文件升级</b>】升级成功！<br/>";
			         }else{
                  echo"【<b>文件升级</b>】解压失败！请手动升级！<br/>";
		           }
            }else{
		          echo"【<b>文件升级</b>】下载升级文件失败！$bzwjc[2]<br/>";
            }
          }else{
		        echo"【<b>文件升级</b>】获取升级文件信息失败！请手动升级！<br/>";
          }
       }
     }else{
		   echo"您已经是最新版本！<br/>";
     }
}else{
	if(!exists('file_get_contents')){
		 echo '你好！请先开启file_get_contents函数';
	}elseif(!exists('preg_match')){
		 echo '你好！请先开启preg_match函数';
	}elseif(!exists('Zip')){
		 echo '你好！你空间不支持在线升级，请手动升级！';
  }else{
$Bingzc=$ubb->content_ubb($Bingzc);
echo"<div class='admin'>在线升级程序<br/></div>";
echo <<< haida
<div class="admin_a">当前程序名称：<font color="#33CC00">$bzxtname</font> <br/></div>
<div class="admin_a">当前系统版本：<font color="#33CC00">$bzxtvbb</font> <br/></div>
<div class="admin_a"><b>官方</b>最新版本：<font color="#FF0000">$Bingza</font> </div>
<div class="admin_a"><b>官方</b>升级时间：<font color="#FF0000">$Bingzb</font> </div>
<div class="admin_a"><b>官方</b>升级介绍：<font color="#FF0000">$Bingzc</font> </div>
haida;
if($Bingza > $bzxtvbb && $Bingzapf > '0'){
	 echo '<div class="admin_a"><a href="admin.php?action=upload&upload=upload">确定在线升级</a><br/></div>';
}
}
}
?>